{% extends 'myadmin/base.html' %}

{% block main_body %}
<div style="height:60px">

</div>
 <div class="card-header">
     <h3 class="card-title"><a href="{% url 'myadmin_index' %}">首页</a> >> <a href="{% url 'myadmin_network_index' %}">网络管理</a> >> 创建网络 </h3>
 </div>
<div style="width:70%; margin-left:15%;">
 <div class="card card-primary">
              <div class="card-header">
                <h3 class="card-title">创建网络</h3>
              </div>
              <!-- /.card-header -->
              <!-- form start -->
              <form action="{% url 'myadmin_network_insert' %}" method="post">
                  {% csrf_token %}
                <div class="card-body">
                  <div class="form-group">
                      <label for="networkname">网络名称<font color="red">*</font></label>
                    <input type="text" class="form-control" id="networkname" name="networkname" placeholder="请输入网络名称">
                  </div>
                  <div class="form-group">
                      <label>启用管理员状态</label>
                    <input type="checkbox"  id="ckadmin" name="ckadmin" checked >
                  </div>
                    <div class="form-group">
                        <label>共享的</label>
                        <input type="checkbox" id="ckshare" name="ckshare">
                    </div>
                    <div class="form-group">
                    <label for="subnetname">子网名称<font color="red">*</font></label>
                    <input type="text" class="form-control" id="subnetname" name="subnetname"  placeholder="请输入子网名称">
                  </div>
                    <div class="form-group">
                    <label for="cird">网络地址<font color="red">*</font></label>
                    <input type="text" class="form-control" id="cird" name="cird" placeholder="请输入网络地址">
                  </div>
                     <div class="form-group">
                    <label >网关</label>
                    <input type="text" class="form-control" name="gateway" id="gateway" placeholder="请输入网关">
                  </div>
                       <div class="form-group">
                         <input type="checkbox"  id="enabledhcp" name="enabledhcp" checked>激活DHCP</input>
                    </div>
                     <div class="form-group">
                    <label >分配地址池</label>
                         <textarea class="form-control" id="iprange" name="iprange" placeholder="请输入IP地址池，每行1条，格式为开始IP,结束IP"></textarea>
                  </div>
                     <div class="form-group">
                    <label >DNS服务器</label>
                         <textarea class="form-control" id="dns" name="dns" placeholder="请输入DNS服务器IP列表，每行1个"></textarea>
                  </div>


                </div>
                <!-- /.card-body -->

                <div class="card-footer">
                  <button type="submit" class="btn btn-primary" onclick="return check();">提交</button>
                    &nbsp; &nbsp;
                    <button type="reset" class="btn btn-primary">重置</button>
                </div>
              </form>
            </div>
</div>
<script>
    function check(){
         networkname = document.getElementById('networkname').value;
         subnetname = document.getElementById('subnetname').value;
         cird = document.getElementById('cird').value;

         info="";

         if(networkname==""){
            info="网络名称不能为空！！\n"
         }

         if(subnetname==""){
            info=info+"子网名称不能为空！！\n"
         }

         if(cird==""){
            info=info+"网络地址不能为空！！\n"
         }

         if(info!=""){
            alert(info);
            return false;
         }


         return true;

    }
</script>

{% endblock %}